package com.zbs.framework.dao.security.service.impl;

import com.zbs.framework.dao.rolefunction.service.model.UserFunctionInfo;
import com.zbs.framework.dao.security.service.SecurityPermissionService;
import com.zbs.framework.security.entity.SecurityUser;
import com.zbs.framework.security.service.SuccessfulAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @description: SuccessfulAuthenticationServiceImpl
 * @author: Zbs
 * @createTime: 2021/3/31 14:25
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SuccessfulAuthenticationServiceImpl implements SuccessfulAuthenticationService {
    @Autowired
    private SecurityPermissionService securityPermissionService;

    @Override
    public void successfulAuthentication(Map<String, Object> loginUserInfo, Map<String, Object> otherInfo, SecurityUser user, String entryType, String token) {
        List<UserFunctionInfo> functionValueList = securityPermissionService.getUserAllFunctionByUserId(user.getLoginUser().getId());
        loginUserInfo.remove("permissions");
        loginUserInfo.put("functions",functionValueList);

    }
}